package com.aurora.source.authority.presenter;

import android.content.Context;

import com.aurora.source.authority.bean.CommodityManagementBean;
import com.aurora.source.authority.view.ICommodityManagementView;
import com.aurora.source.base.BaseBean;
import com.aurora.source.base.BasePresenter;
import com.aurora.source.constant.AuroraConstants;
import com.aurora.source.util.netutil.SubscriberObserver;

import java.util.Map;

public class CommodityManagementPresenter extends BasePresenter<ICommodityManagementView> {

    public CommodityManagementPresenter(ICommodityManagementView baseView) {
        super(baseView);
    }

    public void commodityManagement(Context context, Map<String, String> params) {
        requestMethod.commodityManagement(params, new SubscriberObserver<BaseBean<CommodityManagementBean>>(context,"正在加载中...") {
            @Override
            public void onSuccess(BaseBean<CommodityManagementBean> commodityManagementBeanBaseBean) {
                if (commodityManagementBeanBaseBean.getCode().equals(AuroraConstants.REQUEST_SUCCESS)) {
                    baseView.onCommodityManagementSuccess(commodityManagementBeanBaseBean.getData());
                } else {
                    baseView.onCommodityManagementFail(commodityManagementBeanBaseBean.getMsg());
                }
            }

            @Override
            public void onError(String msg) {
                baseView.onCommodityManagementFail(msg);
            }

            @Override
            public void onFinish() {

            }
        });
    }
}
